home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / xcdplayer / top_setup.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  5KB  |  145 lines

  1. /*
  2.  * Copyright (C) 1990 Regents of the University of California.
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and
  5.  * its documentation for any purpose is hereby granted without fee,
  6.  * provided that the above copyright notice appear in all copies and that
  7.  * both that copyright notice and this permission notice appear in
  8.  * supporting documentation, and that the name of the University of
  9.  * California not be used in advertising or publicity pertaining to
  10.  * distribution of the software without specific, written prior
  11.  * permission.  the University of California makes no representations
  12.  * about the suitability of this software for any purpose.  It is provided
  13.  * "as is" without express or implied warranty.
  14.  */
  15.  
  16. # include <X11/Intrinsic.h>
  17. # include <X11/StringDefs.h>
  18. # include <X11/Shell.h>
  19. # include <X11/Xaw/Form.h>
  20.  
  21. # include <stdio.h>
  22. # include <string.h>
  23.  
  24. # include "cdrom_globs.h"
  25. # include "debug.h"
  26. # include "logo.xbm"
  27.  
  28. XtAppContext    appc;
  29. char        *file;
  30. char        *device;
  31. Boolean        debug        = False;
  32. Boolean        display_timer    = True;
  33. float        volbase        = 187.0;
  34. float        volpcent    = .267;
  35. int        replayThreshold    = 4;
  36. int        pauseSkipInterval    = 15;
  37. int        scanSkipInterval    = 1;
  38. float        scanPauseInterval    = .062;
  39. float        pausePauseInterval    = .500;
  40. char        *cdInfoDir = NULL;
  41.  
  42. extern char    *getenv();
  43.  
  44. static Widget    top_shell;
  45. Widget    top_form_widget;
  46.  
  47. static XrmOptionDescRec options[] = {
  48. { "-file",    ".file",    XrmoptionSepArg,    (caddr_t) NULL },
  49. { "-device",    ".device",    XrmoptionSepArg,    (caddr_t) NULL },
  50. { "-debug",    ".debug",    XrmoptionNoArg,        (caddr_t) "True" },
  51. { "-displayTimer", ".displayTimer", XrmoptionNoArg,    (caddr_t) "True" },
  52. { "-volBase",    ".volBase",    XrmoptionSepArg,    (caddr_t) 0 },
  53. { "-volPcent",    ".volPcent",    XrmoptionSepArg,    (caddr_t) 0 },
  54. { "-cdInfoDir",    ".cdInfoDir",    XrmoptionSepArg,    (caddr_t) NULL },
  55. };
  56.  
  57. static XtResource    resources[] = {
  58.     { "file", "File", XtRString, sizeof(String), (Cardinal) &file,
  59.           XtRString, (caddr_t) NULL },
  60.     { "device", "Device", XtRString, sizeof(String), (Cardinal) &device,
  61.           XtRString, (caddr_t) NULL },
  62.     { "debug", "Debug", XtRBoolean, sizeof(Boolean), (Cardinal) &debug,
  63.           XtRBoolean, (caddr_t) &debug },
  64.     { "displayTimer", "DisplayTimer", XtRBoolean, sizeof(Boolean),
  65.           (Cardinal) &display_timer, XtRBoolean,
  66.           (caddr_t) &display_timer },
  67.     { "volBase", "VolBase", XtRFloat, sizeof(float),
  68.           (Cardinal) &volbase, XtRFloat, (caddr_t) &volbase },
  69.     { "volPcent", "VolPcent", XtRFloat, sizeof(float),
  70.           (Cardinal) &volpcent, XtRFloat, (caddr_t) &volpcent },
  71.     { "replayThreshold", "replayThreshold", XtRInt, sizeof(int),
  72.           (Cardinal) &replayThreshold, XtRInt, 
  73.           (caddr_t) &replayThreshold },
  74.     { "scanSkipInterval", "scanSkipInterval", XtRInt, sizeof(int),
  75.           (Cardinal) &scanSkipInterval, XtRInt, 
  76.           (caddr_t) &scanSkipInterval },
  77.     { "scanPauseInterval", "scanPauseInterval", XtRFloat, sizeof(float),
  78.           (Cardinal) &scanPauseInterval, XtRFloat, 
  79.           (caddr_t) &scanPauseInterval },
  80.     { "pauseSkipInterval", "pauseSkipInterval", XtRInt, sizeof(int),
  81.           (Cardinal) &pauseSkipInterval, XtRInt, 
  82.           (caddr_t) &pauseSkipInterval },
  83.     { "pausePauseInterval", "pausePauseInterval", XtRFloat, sizeof(float),
  84.           (Cardinal) &pausePauseInterval, XtRFloat, 
  85.           (caddr_t) &pausePauseInterval },
  86.     { "cdInfoDir", "cdInfoDir", XtRString, sizeof(String), 
  87.           (Cardinal) &cdInfoDir, XtRString, (caddr_t) NULL },
  88. };
  89.  
  90. Widget
  91. top_setup(argc, argv)
  92.     int        argc;
  93.     char        **argv;
  94. {
  95.     Display        *dpy;
  96.  
  97.     Pixmap        icon_pixmap;
  98.     Arg        arg;
  99.     char        *s;
  100.  
  101.     XtToolkitInitialize();
  102.  
  103.     appc = XtCreateApplicationContext();
  104.  
  105.     dpy = XtOpenDisplay(appc, NULL, "xcdplayer", "XCdplayer",
  106.                 options, XtNumber(options),
  107.                 (Cardinal *) &argc, argv);
  108.  
  109.     if (dpy == NULL) {
  110.         fprintf(stderr, "can't open display\n");
  111.         exit(1);
  112.     }
  113.  
  114.     top_shell = XtAppCreateShell("xcdplayer", "XCdplayer",
  115.                      applicationShellWidgetClass,
  116.                      dpy, (ArgList) NULL, 0);
  117.  
  118.     icon_pixmap = XCreateBitmapFromData(XtDisplay(top_shell),
  119.                 RootWindowOfScreen(XtScreen(top_shell)),
  120.                 logo_bits, logo_width, logo_height);
  121.     
  122.     XtSetArg(arg, XtNiconPixmap, icon_pixmap);
  123.     XtSetValues(top_shell, &arg, 1);
  124.     
  125.  
  126.     (void) XtGetApplicationResources(top_shell, (caddr_t) NULL,
  127.                      resources, XtNumber(resources),
  128.                      (ArgList) NULL, 0);
  129.  
  130.     if ((cdInfoDir == NULL) && ((s=getenv("XCDINFODIR")) != NULL))
  131.         cdInfoDir = strdup(s);
  132.  
  133.     top_form_widget = XtCreateWidget("mainForm", formWidgetClass,
  134.                          top_shell,
  135.                          (ArgList) NULL, 0);
  136.  
  137.     return(top_form_widget);
  138. }
  139.  
  140. void
  141. top_start() {
  142.     XtManageChild(top_form_widget);
  143.     XtRealizeWidget(top_shell);
  144. }
  145.